using UnityEditor;

namespace ZhenG
{
    public class AssetImporter : AssetPostprocessor
    {
        private void OnPreprocessAsset()
        {
            if (assetImporter is AudioImporter audioImporter)
            {
                ConfigureAudio(audioImporter);
            }

            if (assetImporter is TextureImporter textureImporter)
            {
                ConfigureTexture(textureImporter);
            }
        }

        private void ConfigureTexture(TextureImporter importer)
        {
            if (!assetPath.Contains("UI/"))
                return;
            importer.textureType = TextureImporterType.Sprite;
            importer.spriteImportMode = SpriteImportMode.Single;
            importer.mipmapEnabled = false;
        }

        private void ConfigureAudio(AudioImporter importer)
        {
            if (!assetPath.Contains("Audios/"))
                return;
            importer.forceToMono = true;
        }
    }
}